#检验类型
# a = { }
# b = dict()
# print(type(a))
# print(type(b))

# student={1:"张三",2:"李四",3:"王五"}
# print(student)
#用in判定是否存在
# #这里的“\”表示换行，删掉就会报错
# student = \
#     {
#     'id': 1,
#     'name': 'zhangsan',
#     }
# print('id' in student)
# print('score' in student)
# #用[]获取键值
# print(student['id'])
# print(student['name'])
# #如果不存在则抛异常
# print(student['score'])
#果 key 不存在, 对取下标操作赋值, 即为新增键值对
# student = \
#     {
#     'id': 1,
#     'name': 'zhangsan',
#     }
# student['score'] = 90
# print(student)
#
# student = {
#     'id': 1,
#     'name': 'zhangsan',
#     'score': 80
# }
# student['score'] = 90
# print(student)
#删除元素
#使用 pop 方法根据 key 删除对应的键值对
# student = {
# 'id': 1,
# 'name': 'zhangsan',
# 'score': 80
# }
# student.pop('score')
# print(student)
#遍历字典元素
# student = {
# 'id': 1,
# 'name': 'zhangsan',
# 'score': 80
# }
# #遍历
# for key in student:
#     print(key, student[key])
# #取出所有key和value
# print(student.keys())
# print(student.values())
# print(student.items())
# #计算是否为合法key
# print(hash(0))
# print(hash(3.14))
# print(hash('hello'))
# print(hash(True))
# print(hash(())) # ( ) 是一个空的元组
# print(hash([1, 2, 3]))
# print(hash({ 'id': 1 }))
f = open(r'D:/Python/python---learning/hello world.txt', 'a')
f.write('诗华')
f.close()
f = open(r'D:/Python/python---learning/hello world.txt', 'w')
f.write('诗华')
f.close()